package com.vodone.v1pin.video.delegate
{
	
	import com.vodone.v1pin.index.vo.PicVO;
	import com.vodone.v1pin.video.view.vo.VideoConditionVO;
	import com.vodone.v1pin.video.view.vo.VideoVO;

	public class VideoConvertUtil
	{
		public static function getReplyPicList(obj:Object):Array
		{
			var temp:Array = [];
			var list:Array;
			var level:int = 0;
			if( obj.hasOwnProperty("data") )
			{
				list = obj["data"];
				var len:int = list.length;
				for( var i:int = 0 ; i < len ; i++ ){
					temp.push( getVideo( list[i] ) );
				}
			}
			
			return temp;
		}
		
		public static function getVideo( obj:Object ):VideoVO
		{
			var vo:VideoVO = new VideoVO();
			if( obj.hasOwnProperty("id") )
			{
				vo.autoid = obj["id"];
			}
			if( obj.hasOwnProperty("name") )
			{
				vo.VideoName = obj["name"];
			}
			if( obj.hasOwnProperty("url") )
			{
				vo.VideoUrl = obj["url"];
			}
			if( obj.hasOwnProperty("img") )
			{
				vo.VideoImg = obj["img"];
			}
			if( obj.hasOwnProperty("ProductCode") )
			{
				vo.ProductCode = obj["ProductCode"];
			}
			
			return vo;
		}
		
		public static function getPicList( obj:Object ):Array
		{
			var temp:Array = [];
			var list:Array;
			var level:int = 0;
			if( obj.hasOwnProperty("data") )
			{
				list = obj["data"];
				var len:int = list.length;
				for( var i:int = 0 ; i < len ; i++ ){
					temp.push( getPic( list[i] ) );
				}
			}
			
			return temp;
		}
		
		public static function getPic( obj:Object ):PicVO
		{
			var vo:PicVO = new PicVO();
			if( obj.hasOwnProperty("url") )
			{
				vo.url = obj["url"];
			}
			if( obj.hasOwnProperty("proid") )
			{
				vo.id = obj["procode"];
			}
			if( obj.hasOwnProperty("videourl") )
			{
				vo.videourl = obj["videourl"];
			}
			if( obj.hasOwnProperty("procode") )
			{
				vo.procode = obj["proid"];
			}
			
			return vo;
		}
		
		public static function getReplyConditionList(obj:Object,index:int = 1):Array
		{
			var list:Array;
			var temp:Array;
			if( obj.hasOwnProperty("data1") )
			{
				list = obj["data"+index];
				temp = new Array();
				var len:int = list.length;
				for( var i:int = 0 ; i < len ; i++ ){
					temp.push( getCondition( list[i] ) );
				}
			}
			
			return temp;
		}
		
		public static function getCondition( obj:Object ):VideoConditionVO
		{
			var vo:VideoConditionVO = new VideoConditionVO();
			if( obj.hasOwnProperty("id") )
			{
				vo.id = obj["id"];
			}
			if( obj.hasOwnProperty("name") )
			{
				vo.name = obj["name"];
			}
			
			return vo;
		}
	}
}